using UnityEngine;
using System.Collections;

public class DestructibleObject : MonoBehaviour {


	public int Type = 1; //1 = caisse, 2 porte
	public int life = 4;

	void Update()
	{
		if (Type == 2)
		{
			this.collider.isTrigger = false;
			//this.rigidbody.useGravity = true;
		}
	}

	void OnTriggerEnter(Collider other)
	{
		if (other.tag == "Player" && Type == 1)
		{
			LevelGenerator.sSpeed /= 2;
			Destroy(this.gameObject);
		}

		if (other.tag == "Bullet" && Type == 2)
		{
			life--;
			if (life <= 0)
			{
				Destroy(this.gameObject);
			}
			Destroy(other.gameObject);
		}
	}

}
